import { Controller, Get, Request } from '@nestjs/common';
import { ApiUseTags } from '@nestjs/swagger';
import { ApiResult } from '../config/index';
import { TasksService } from './tasks.service';
import { TasksPuppeteerService } from './tasks.puppeteer.service';

@Controller('task')
@ApiUseTags('Task管理')
export class TaskController {
  constructor(private readonly taskService: TasksPuppeteerService) {}

  @Get('run')
  async run(@Request() request): Promise<ApiResult> {
    // return ApiResult.SUCCESS(await this.newsService.fetchSituation());
    const res = await this.taskService.run();
    return ApiResult.SUCCESS(res);
  }
}
